package com.lhd_gm.scheduledtasksystem.utils;

import com.lhd_gm.scheduledtasksystem.pojo.ShellTask;

import java.io.File;

public class shelltest {
    public static void main(String[] args) {
        ShellTask shellTask = new ShellTask();
        File scriptFile = new File("ScheduledTaskSystem/src/main/resources/static/shell/test.sh");
        String absoluteScriptPath = scriptFile.getAbsolutePath();
        System.out.println(absoluteScriptPath);
        shellTask.setFileName("test.sh");
        shellTask.setShell("已有脚本");
        shellTask.setJobType("shell");
        shellTask.setDescription(null);
        shellTask.setScriptArgs(null);
        shellTask.setTimeout(3000);
        shellTask.setWorkDir(null);
        shellTask.setEnvVars(null);
        try {
            int code = ShellExecutor.executeScript(shellTask,absoluteScriptPath);
            System.out.println(code);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
